<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>当当网后台管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <style type="text/css">
        .layui-tab-content {
            padding: 0;/*layui-tab-content:默认有padding: 10px;的值，因为iframe的绝对定位脱离文档流，所以会存在20px的空白空间*/
        }
        .show-frame {
            top: 50px!important;
            /*默认.layui-layout-admin .layui-body {
                top: 60px;
                bottom: 44px;
            }*/
            overflow: hidden;/*消除浏览器最右边的滚动条*/
        }
        .frame {
            position: absolute;
            padding: 10px;/*与layui-footer隔开一段距离*/
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">当当网后台管理</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="${pageContext.request.contextPath}/img/5f5ee5de-17b9-46a7-b435-17aac52022c1888.jpg" class="layui-nav-img">
                    用户名：${user.nickname}
                </a>
            </li>
            <li class="layui-nav-item" id="goOut"><a id="gogo">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:void(0); "tab_id="2" page_src="show.jsp">查看所有商品</a></dd>
                        <dd><a href="javascript:void(0);" tab_id="1" page_src="add.jsp">添加商品</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <div class="layui-tab" lay-filter="myTab">
            <ul class="layui-tab-title" >
                <li class="layui-this">欢迎界面</li>

            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">欢迎当当网后台管理</div>
            </div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>
<script src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
<script>
    if(${user==null}){
        location.href="login.jsp";
    }
    //JavaScript代码区域
    layui.use(['element','layer'], function(){
        var layer = layui.layer;
        var element = layui.element;
        $("dl.layui-nav-child a").click(function () {
            var title = $(this).html()
            var id=$(this).attr("tab_id");
            var page_src=$(this).attr("page_src");
            if ($("li[lay-id="+id+"]").size()==0){
                element.tabAdd("myTab",{
                    title:title,
                    content:"<iframe class='frame' src="+page_src+"></iframe>",
                    id:id
                });
                element.tabChange("myTab",id);
            }
        });
        $("#goOut").click(function () {
            layer.confirm("是否退出",function (index) {
                $.ajax({
                    url:"${pageContext.request.contextPath}/useres",
                    type:"DELETE",
                    success:function () {
                        location = "login.jsp";
                    }
                });
            })
        })
    });


</script>
</body>
</html>